package com.fenghongzhang.day009;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;

import com.fenghongzhang.day009.fragment.LoginFragment;
import com.fenghongzhang.day009.fragment.RegisterFragment;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity implements LoginFragment.Mylistener {
    private ViewPager vp;

    private LoginFragment loginFragment;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        vp = (ViewPager) findViewById(R.id.vp);

        List<Fragment> list = new ArrayList<>();
        loginFragment = new LoginFragment();
        loginFragment.setMylistener(this);
        list.add(loginFragment);
        list.add(new RegisterFragment());

        LoginAndRegisterAdapter loginAndRegisterAdapter = new LoginAndRegisterAdapter(getSupportFragmentManager(), list);
        vp.setAdapter(loginAndRegisterAdapter);

        //
        vp.setPageTransformer(true,new DepthPageTransformer());



    }

    @Override
    public void click(int i) {
        vp.setCurrentItem(i);
    }
}
